<?php

$view = '
<div class="view split-view">
	
	<!-- '. $module_name .' List -->
	<div class="view">
		';
		$data['module_name_lower'] = $module_name_lower;
		$data['field_total'] = $field_total;
		$view .= $this->load->view('files/view_side_form', $data, TRUE);
$view .= '
		
	</div>
	
	<!-- '. $module_name .' Editor -->
	<div id="content" class="view">
		<div class="scrollable" id="ajax-content">
				
			<div class="box create rounded">
				<a class="button good" href="<?php echo site_url(SITE_AREA .\'/'.$controller_name.'/'.$module_name_lower.'/create\')?>"><?php echo lang(\''.$module_name_lower.'_create_new_button\');?></a>

				<h3><?php echo lang(\''.$module_name_lower.'_create_new\');?></h3>

				<p><?php echo lang(\''.$module_name_lower.'_edit_text\'); ?></p>
			</div>
			<br />
				<?php if (isset($records) && is_array($records) && count($records)) : ?>
				
					<h2>'.$module_name.'</h2>
	<form method="post" action="<?php echo base_url() . SITE_AREA . \'/'.$controller_name.'/'.$module_name_lower.'/bulk\' ?>" onSubmit="return confirm(\'<?php echo lang(\''.$module_name_lower.'_bulk_confirm\') ?>\')" class="table-form">
	<div>
		<div class="table-top-left-container">
			<div class="table-action">
				<label for="action"><?php echo lang(\''.$module_name_lower.'_with_selected\') ?>:</label> 
				<div class="input">
					<select name="action">
						<option value="delete"><?php echo lang(\''.$module_name_lower.'_delete\') ?></option>
					</select> 
					&nbsp;&nbsp;
					<input type="submit" name="apply" value="<?php echo lang(\''.$module_name_lower.'_apply\') ?>">
				</div>
			</div>
		</div>
		<div class="table-top-right-container">
			<div class="total-rows"><?php echo lang(\''.$module_name_lower.'_total_rows\'); ?>: <?php echo $total_rows; ?></div>
		</div>
	</div>
	
	<table>
		<thead>
			<tr>
			<th style="width: 2em"><input class="check-all" type="checkbox"></th>';

for($counter=1; $field_total >= $counter; $counter++)
{
	// only build on fields that have data entered. 

	//Due to the requiredif rule if the first field is set the the others must be

	if (set_value("view_field_label$counter") == NULL)
	{
		continue; 	// move onto next iteration of the loop
	}
	$view .= '
		<th>'. set_value("view_field_label$counter").'</th>';
}
if ($use_soft_deletes == 'true')
{
	$view .= '
		<th>Deleted</th>';
}
if ($use_created == 'true')
{
	$view .= '
		<th>Created</th>';
}
if ($use_modified == 'true')
{
	$view .= '
		<th>Modified</th>';
}

$view .= '
		<th><?php echo lang(\''.$module_name_lower.'_actions\'); ?></th>
		</tr>
		</thead>
		<tbody>
<?php
foreach ($records as $record) : ?>
			<tr>';
			
$view .= '
				<td class="column-check"><input type="checkbox" value="<?php echo $record->id?>" name="checked[]">
';
for($counter=1; $field_total >= $counter; $counter++)
{
	// only build on fields that have data entered. 

	//Due to the requiredif rule if the first field is set the the others must be

	if (set_value("view_field_name$counter") == NULL || set_value("view_field_name$counter") == $primary_key_field)
	{
		continue; 	// move onto next iteration of the loop
	}
	$view .= '
				<td><?php echo $record->'.$module_name_lower.'_'.set_value("view_field_name$counter").'?></td>';
}
if ($use_soft_deletes == 'true')
{
	$view .= '
				<td><?php echo $record->deleted > 0 ? lang(\''.$module_name_lower.'_true\') : lang(\''.$module_name_lower.'_false\')?></td>';
}
if ($use_created == 'true')
{
	$view .= '
				<td><?php echo $record->'.set_value("created_field").'?></td>';
}
if ($use_modified == 'true')
{
	$view .= '
				<td><?php echo $record->'.set_value("modified_field").'?></td>';
}
$view .= '
				<td><?php echo anchor(SITE_AREA .\'/'.$controller_name.'/'.$module_name_lower.'/edit/\'. $record->'.$primary_key_field.', lang(\''.$module_name_lower.'_edit\'), \'class=""\'); ?></td>
			</tr>
<?php endforeach; ?>
		</tbody>
	</table>
	</form>
	<div class="table-bottom-container">
		<?php echo $this->pagination->create_links(); ?>
	</div>
				<?php else : ?>
		
					<div class="notification attention">
						<p><?php echo lang(\''.$module_name_lower.'_no_records\'); ?></p>
					</div>
					
				<?php endif; ?>
				
		</div>	<!-- /ajax-content -->
	</div>	<!-- /content -->
</div>
';

	echo $view;
?>